game_manager
{
spawn
{

		create
		{
			scriptName "bugfix1"
			classname "func_fakebrush"
			origin "720 475 10"
			contents 65536  // CONTENTS_PLAYERCLIP
			mins "-20 -40 -30"
			maxs "1 40 30"
		}
		
		create
		{
			scriptName "bugfix2"
			classname "func_fakebrush"
			origin "1250 -2970 -165"
			contents 65536  // CONTENTS_PLAYERCLIP
			mins "-50 -40 -100"
			maxs "50 0 0"
		}

		create
		{
			scriptName "bugfix3"
			classname "func_fakebrush"
			origin "788 -1817 88"
			contents 65536  // CONTENTS_PLAYERCLIP
			mins "-11 -10 -30"
			maxs "1 10 30"
		}

		create
		{
			scriptName "bugfix4"
			classname "func_fakebrush"
			origin "704 -1789 80"
			contents 65536  // CONTENTS_PLAYERCLIP
			mins "-10 -10 -30"
			maxs "10 10 30"
		}


// Set scenario information
wm_axis_respawntime 30
wm_allied_respawntime 20
wm_number_of_objectives 5
wm_set_round_timelimit 15

//Adlernest mapscript by Dersaidin

// 0  is axis
wm_set_defending_team 0
wm_setwinner 0

//Take docs
wm_objective_status 1 1 0
wm_objective_status 1 0 0
//Cap docs
wm_objective_status 2 1 0
wm_objective_status 2 0 0
//CP
wm_objective_status 3 1 0
wm_objective_status 3 0 0
//Doors
wm_objective_status 4 1 0
wm_objective_status 4 0 0
//Maindoor
wm_objective_status 5 1 0
wm_objective_status 5 0 1

//main opjective is to cap docs
wm_set_main_objective 2 1
wm_set_main_objective 2 0

// Cap docs
accum 1 set 0
//Take docs
accum 2 set 0
//Allied CP built once
accum 3 set 0
//Maindoorr, 1=open 0=closed 2=working
accum 4 set 0
//Maindoorl, 1=open 0=closed 2=working
accum 5 set 0
//Allied CP _IS_ built
globalaccum 6 set 0

wait 1250
trigger phasedoor1 move_up
trigger maindoorr move_up
trigger phasedoor2 move_up

trigger tank_turret facewall
      delete
      {
         origin "-65 -2428 -292"   
      }
      delete
      {
         origin "733 -2971 -120"   
      }

}



trigger startvos
{

}

trigger cap_docs
{
	//cap docs: true
	wm_objective_status 2 1 1
	wm_objective_status 2 0 2
	//cap docs: true
	accum 1 set 1
	wm_announce "Allied team has transmitted the documents!"
	trigger game_manager checkgame
}

trigger axis_object_stolen
{
	//wm_announce	"Allies have stolen the documents!"
	wm_objective_status 1 1 1
	accum 2 set 1
}

trigger axis_object_returned
{
	//wm_announce	"The documents have been returned!"
	wm_objective_status 1 1 0
	accum 2 set 0
	accum 1 set 0
}

trigger checkgame
{
	accum 1 abort_if_not_equal 1
	wm_setwinner 1
	wait 100
	wm_endround
}
}

transmitter_obj
{
	spawn
	{
	}
	death
	{
		trigger game_manager cap_docs
	}
}
neuetuer
{
	spawn
	{
	wait 20         
	}
	trigger open
	{   
		set
		{
		allowteams "7"
		wm_announce	"Tuer auf!"
		}
	}
}

documents
{
    spawn
    {
	    wait 200
    }
    trigger stolen 
    {
    	//when the objective is taken 
    	// Hide command map marker of docs at table
    	setstate documents_CMM invisible 
	}
	trigger dropped
	{
		//when the player carrying the objective is killed 
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 1 "allies_hq_objective_lost"
		// *---------------------------------------------------------------------------------*
	}
	trigger returned
	{
		//when defending team touches the dropped objective
		// Show command map marker of docs at table
		setstate documents_CMM default
	} 
	trigger captured
	{
		//when the objective is delivered to its deliverypoint 
		
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_objective_lost"
		wm_teamvoiceannounce 1 "allies_hq_objective_captured"
		// *---------------------------------------------------------------------------------*
	}
}

doorcontrols
{
	spawn 
	{
		set
		{
		constructible_class 1
		health "400"
		}
	}
	death
	{
	
		trigger doornwall on
		trigger doorob off
		trigger phasedoor2 move_up				
		wm_objective_status 4 1 1		
		wm_objective_status 4 0 2
		// Open phase doors
				
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 1 "allies_hq_objective_destroyed"

		wm_removeteamvoiceannounce 0 "adlernest_axis_controls_defend"
		wm_removeteamvoiceannounce 1 "adlernest_allies_controls_destroy"
		
		// "Construct the command post!" voice over, unless its already been done.
        	globalaccum 6 abort_if_equal 1
        		
		wm_teamvoiceannounce 1 "allies_hq_compost_construct"
		// *---------------------------------------------------------------------------------*
	}
}

phasedoor1
{
	spawn
	{
		wait 200
		gotomarker phasedoor1_pc2 1000
	}
	
	trigger move_up
	{
		wait 100
		trigger neuetuer open
		playsound sound/movers/misc/garage_door_start_01.wav
		playsound sound/movers/misc/garage_door_loop_01.wav looping forever
		gotomarker phasedoor1_pc1 80 wait
		stopsound
		playsound sound/movers/misc/garage_door_end_01.wav
	}
}

phasedoor2
{
	spawn
	{
		wait 200
		gotomarker phasedoor2_pc2 1000
	}
	
	trigger move_up
	{
		wait 100
		playsound sound/movers/misc/garage_door_start_01.wav
		playsound sound/movers/misc/garage_door_loop_01.wav looping forever
		gotomarker phasedoor2_pc1 80 wait
		stopsound
		playsound sound/movers/misc/garage_door_end_01.wav
	}
}

maindoor_button
{
	spawn
	{
		wait 200
	}
	
	activate
	{		
		trigger maindoorr move_up
		trigger maindoorl move_up
		
		trigger maindoorr move_down
		trigger maindoorl move_down
	}
}

maindoor_lever
{
	spawn
	{
		wait 200
		trigger maindoor_lever move_down
	}
	
	trigger move_down
	{
		wait 200
		faceangles 0 0 -1 750
	}
	
	trigger move_up
	{
		wait 200
		faceangles 0 0 -25 750
	}
}

maindoor_lever1
{
	spawn
	{
		wait 200
		trigger maindoor_lever1 move_down
	}
	
	trigger move_down
	{
		wait 200
		faceangles -1 0 0 750
	}
	
	trigger move_up
	{
		wait 200
		faceangles -25 0 0 750
	}
}

maindoorr
{
	spawn
	{
		wait 200
		gotomarker maindoorr_pc2 1000
	}
	
	trigger move_up
	{
		// open
		// abort if working or opened
		accum 4 abort_if_equal 2
		accum 4 abort_if_equal 1
		// set status working
		accum 4 set 2
		
		trigger maindoor_lever move_up
		trigger maindoor_lever1 move_up
		wm_objective_status 5 1 1
		wm_objective_status 5 0 0
		
		wait 500
		playsound sound/movers/misc/big_gate1.wav
		wait 400
		playsound sound/movers/misc/big_gate2.wav looping forever
		gotomarker maindoorr_pc1 45 wait
		stopsound
		playsound sound/movers/misc/big_gate3.wav
		// set status opened
		accum 4 set 1
	}
	
	trigger move_down
	{
		// close
		// abort if working or closed
		accum 4 abort_if_equal 2
		accum 4 abort_if_equal 0
		// set status working
		accum 4 set 2
		
		trigger maindoor_lever move_down
		trigger maindoor_lever1 move_down
		wm_objective_status 5 1 0
		wm_objective_status 5 0 1
		
		wait 500
		playsound sound/movers/misc/big_gate1.wav
		wait 400
		playsound sound/movers/misc/big_gate2.wav looping forever
		gotomarker maindoorr_pc2 45 wait
		stopsound
		playsound sound/movers/misc/big_gate3.wav
		// set status closed
		accum 4 set 0
	}
}

maindoorl
{
	spawn
	{
		wait 200
		gotomarker maindoorl_pc2 1000
	}
	
	trigger move_up
	{
		// open
		// abort if working or opened
		accum 5 abort_if_equal 2
		accum 5 abort_if_equal 1
		// set status working
		accum 5 set 2
		
		wm_announce "Main blast door changing!"
		
		wait 500
		playsound sound/movers/misc/big_gate1.wav
		wait 400
		playsound sound/movers/misc/big_gate2.wav looping forever
		gotomarker maindoorl_pc1 45 wait
		stopsound
		playsound sound/movers/misc/big_gate3.wav
		// set status opened
		accum 5 set 1
	}
	
	trigger move_down
	{
		// close
		// abort if working or closed
		accum 5 abort_if_equal 2
		accum 5 abort_if_equal 0
		// set status working
		accum 5 set 2
		
		wm_announce "Main blast door changing!"
		
		wait 500
		playsound sound/movers/misc/big_gate1.wav
		wait 400
		playsound sound/movers/misc/big_gate2.wav looping forever
		gotomarker maindoorl_pc2 45 wait
		stopsound
		playsound sound/movers/misc/big_gate3.wav
		// set status closed
		accum 5 set 0
	}

}


//
//
//  CP CP CP CP
//
//

allied_radio_built
{
   spawn
   {
      wait 400

      constructible_class 2

      trigger allied_radio_built setup
      
      disablespeaker allied_compost_sound    
   }

   trigger setup
   {     
      setchargetimefactor 1 soldier 1
      setchargetimefactor 1 lieutenant 1
      setchargetimefactor 1 medic 1
      setchargetimefactor 1 engineer 1
      setchargetimefactor 1 covertops 1
      sethqstatus 1 0
   }

   buildstart final
   {
      trigger allied_radio_built_model trans
      trigger neutral_radio_closed_model  hide
   }

   built final
   {
      trigger allied_radio_built_model show
      trigger allied_radio_built_model enable_allied_features
	trigger doornwall on
	trigger doorob off
      enablespeaker allied_compost_speaker
   }

   decayed final
   {
      trigger allied_radio_built_model hide
      trigger neutral_radio_closed_model show
   }

   death
   {
      trigger allied_radio_built_model hide
      trigger allied_radio_built_model disable_allied_features
      trigger neutral_radio_closed_model show

      disablespeaker allied_compost_sound
   }
}

allied_radio_built_model
{
   spawn
   {
      wait 400
      setstate allied_radio_built_model invisible
      accum 3 set 0
   }

   trigger show
   {
      setstate allied_radio_built_model default
      setstate allied_radio_built default
      setstate alliedhqradio_toi default
   }

   trigger hide
   {
      setstate allied_radio_built_model invisible
      //setstate allied_radio_built invisible
      //setstate alliedhqradio_toi invisible
 
   }

   trigger trans
   {
      setstate allied_radio_built_model underconstruction
      setstate allied_radio_built default
      
      //setstate alliedhqradio_toi invisible
   }

   trigger enable_allied_features
   {
	   
      setchargetimefactor 1 soldier 0.75
      setchargetimefactor 1 lieutenant 0.75
      setchargetimefactor 1 medic 0.75
      setchargetimefactor 1 engineer 0.75
      setchargetimefactor 1 covertops 0.75
      sethqstatus 1 1

      wm_announce   "Allied Command Post constructed. Charge speed increased!"
      
      globalaccum 6 set 1
            
      // *----------------------------------- vo ------------------------------------------*
      wm_teamvoiceannounce 0 "axis_hq_compost_constructed_allies"
      
      wm_teamvoiceannounce 1 "allies_hq_compost_constructed"

	  wm_removeteamvoiceannounce 1 "allies_hq_compost_construct"
      // *----------------------------------- vo ------------------------------------------*

      wm_objective_status 3 0 2
      wm_objective_status 3 1 1
      
      // ENABLE NEW SPAWN
      trigger cp_spawn_wobj on
      
      // If first time, then set new spawn as default
      accum 3 abort_if_equal 1
      accum 3 set 1      
      
      setautospawn    "CP Spawn"   1
   }

   trigger disable_allied_features
   {
      // Some kind of UI pop-up to alert players
      wm_announce   "Axis team has destroyed the Allied Command Post!"

      //DISABLE NEW SPAWN
      trigger cp_spawn_wobj off
      
      globalaccum 6 set 0
      
      // *----------------------------------- vo ------------------------------------------*    
      wm_addteamvoiceannounce 1 "allies_hqt_compost_construc"

	  wm_teamvoiceannounce 1 "allies_hq_compost_damaged"
      // *----------------------------------- vo ------------------------------------------*

      setchargetimefactor 1 soldier 1
      setchargetimefactor 1 lieutenant 1
      setchargetimefactor 1 medic 1
      setchargetimefactor 1 engineer 1
      setchargetimefactor 1 covertops 1
      sethqstatus 1 0

      wm_objective_status 3 0 0
      wm_objective_status 3 1 0
   }

} 

neutral_radio_closed_model
{
   spawn
   {
      wait 400
      //setstate neutral_radio_closed_model default
      trigger neutral_radio_closed_model show
                  
      sethqstatus 0 0

      wm_objective_status 3 1 0
      wm_objective_status 3 0 0     
      
      //setstate alliedhqradio_toi default
      //setstate alliedhqradio_toi invisible
      
   }

   trigger show
   {
      setstate neutral_radio_closed_model default
      //setstate neutral_radio_closed default
      
      //setstate alliedhqradio_toi invisible
   }

   trigger hide
   {
      setstate neutral_radio_closed_model invisible
      //setstate neutral_radio_closed invisible
   }
} 

neutral_radio_closed
{
   spawn
   {
      wait 400    
   }
}

cp_spawn_spawns
{
   	spawn
	{
	  wait 50
	  setstate cp_spawn_spawns invisible
	}
} 

cp_spawn_wobj
{
   	spawn
	{
	  wait 200
	  setstate cp_spawn_wobj invisible
	}
	trigger off
    {
      setstate cp_spawn_wobj invisible
      setstate cp_spawn_spawns invisible
	  alertentity cp_spawn_spawns
	  wm_announce "Allied Command Post spawn disabled!"
    }
    trigger on
    {
      setstate cp_spawn_wobj default
      setstate cp_spawn_spawns default
	  alertentity cp_spawn_spawns
      wm_announce "Allied Command Post spawn active!"
    }
	trigger allied_capture 
	{
		//
	}
    trigger axis_capture
    {
	    //
    }
} 

allied_spawn
{
   	spawn
	{
	  wait 200
	}
} 

allied_spawn_flag
{
   	spawn
	{
	  wait 200
	}
	trigger allied_capture 
	{
		//
	}
    trigger axis_capture
    {
	    //
    }
} 

tank_turret
{
	spawn
	{
		wait 200
	}
	
	trigger facewall
	{
		trigger tank_turret spin_start
		faceangles 0 150 0 1000
		trigger tank_turret spin_stop
		trigger tank_turret spin_fire
		alertentity sidewall
	}
	
	trigger spin_fire
	{
		playsound sound/vehicles/tank/tank_fire.wav volume 560
	}

	trigger spin_start
	{
		stopsound
		playsound sound/vehicles/tank/turret_spin.wav looping volume 155
	}

	trigger spin_stop
	{
		stopsound
		playsound sound/vehicles/tank/turret_end.wav volume 135
	}
}

sidewall
{
	spawn
	{
		wait 200
	}
	death
	{
		alertentity sidewall_explo
	}
}

sidewall_explo
{
	spawn
	{
		wait 200
	}
}

//////////// Hide & Seek stuff, by sani

lift
{
	spawn
	{
		globalaccum 0 set 0 				// LIFT IS AT 1ST FLOOR
		setstate down_arrow invisible
		wait 1000
		trigger self 1st_to_2nd
	}
	
///////////////////////// OPEN/CLOSE LIFT DOORS

	trigger close_1doors
	{
		trigger lift_f1_d1 close
		trigger lift_f1_d2 close
	}
	trigger close_2doors
	{
		trigger lift_f2_d1 close
		trigger lift_f2_d2 close
	}
	trigger close_3doors
	{
		trigger lift_f3_d1 close
		trigger lift_f3_d2 close
	}
	trigger open_1doors
	{
		trigger lift_f1_d1 open
		trigger lift_f1_d2 open
	}
	trigger open_2doors
	{
		trigger lift_f2_d1 open
		trigger lift_f2_d2 open
	}
	trigger open_3doors
	{
		trigger lift_f3_d1 open
		trigger lift_f3_d2 open
	}


///////////////////////// LIFT MOVEMENT

	trigger move_up
	{
		globalaccum 0 trigger_if_equal 0 lift 1st_to_2nd	// DO IF LIFT AT 1ST FLOOR
		globalaccum 0 trigger_if_equal 1 lift 2nd_to_3rd	// DO IF LIFT AT 2ND FLOOR
	}
	trigger move_down
	{
		globalaccum 0 trigger_if_equal 1 lift 2nd_to_1st	// DO IF LIFT AT 2ND FLOOR
		globalaccum 0 trigger_if_equal 2 lift 3rd_to_2nd	// DO IF LIFT AT 3RD FLOOR
	}

	// GOING UP /\
	trigger 1st_to_2nd
	{
		globalaccum 0 abort_if_not_equal 0
		trigger self close_1doors
		wait 1500

		setstate down_arrow invisible
		setstate up_arrow default

		playsound sound/movers/lift/elev1_start.wav
		wait 500
		stopsound

		playsound sound/movers/lift/elev1_loop.wav looping
		gotomarker lift_f2path 100 accel deccel
		wait 8000
		stopsound
		playsound sound/movers/lift/elev1_end.wav

		wait 500
		trigger self open_2doors
		globalaccum 0 set 1
		wait 5000
		trigger self 2nd_to_3rd
	}
	trigger 2nd_to_3rd
	{
		globalaccum 0 abort_if_not_equal 1
		trigger self close_2doors
		wait 1500

		setstate down_arrow invisible
		setstate up_arrow default

		playsound sound/movers/lift/elev1_start.wav
		wait 500
		stopsound
		playsound sound/movers/lift/elev1_loop.wav looping
		gotomarker lift_f3path 100 accel deccel

		wait 3500
		stopsound
		playsound sound/movers/lift/elev1_end.wav

		wait 500
		trigger self open_3doors
		globalaccum 0 set 2
		wait 5000
		trigger self 3rd_to_2nd
		
	}
	
	// GOING DOWN \/
	trigger 2nd_to_1st
	{
		globalaccum 0 abort_if_not_equal 1
		trigger self close_2doors
		wait 1500
		setstate up_arrow invisible
		setstate down_arrow default

		playsound sound/movers/lift/elev1_start.wav
		wait 500
		stopsound
		playsound sound/movers/lift/elev1_loop.wav looping
		gotomarker lift_f1path 100 accel deccel

		wait 8000
		stopsound
		playsound sound/movers/lift/elev1_end.wav

		wait 500
		trigger self open_1doors
		globalaccum 0 set 0
		wait 5000 
		trigger self 1st_to_2nd 
		
	}
	trigger 3rd_to_2nd
	{
		globalaccum 0 abort_if_not_equal 2
		trigger self close_3doors
		wait 1500

		setstate up_arrow invisible
		setstate down_arrow default

		playsound sound/movers/lift/elev1_start.wav
		wait 500
		stopsound
		playsound sound/movers/lift/elev1_loop.wav looping
		gotomarker lift_f2path 100 accel deccel

		wait 3500
		stopsound
		playsound sound/movers/lift/elev1_end.wav

		wait 500
		trigger self open_2doors
		globalaccum 0 set 1
		wait 5000
		trigger self 2nd_to_1st
	}
}

lift_f1_d1
{
	spawn
	{
		wait 200
	}
	trigger open
	{
		gotomarker lift_f1_d1open 70 deccel wait
	}
	trigger close
	{
		gotomarker lift_f1_dclose 70 deccel wait
	}
}

lift_f1_d2
{
	spawn
	{
		wait 200
	}
	trigger open
	{
		gotomarker lift_f1_d2open 140 deccel wait
	}
	trigger close	
	{
		gotomarker lift_f1_dclose 140 deccel wait
	}
}

lift_f2_d1
{
	spawn
	{
		wait 200
	}
	trigger open
	{
		gotomarker lift_f2_d1open 70 deccel wait
	}
	trigger close
	{
		gotomarker lift_f2_dclose 70 deccel wait
	}
}

lift_f2_d2
{
	spawn
	{
		wait 200
	}
	trigger open
	{
		gotomarker lift_f2_d2open 140 deccel wait
	}
	trigger close	
	{
		gotomarker lift_f2_dclose 140 deccel wait	
	}
}

lift_f3_d1
{
	spawn
	{
		wait 200
	}
	trigger open
	{
		gotomarker lift_f3_d1open 70 deccel wait
	}
	trigger close
	{
		gotomarker lift_f3_dclose 70 deccel wait
	}
}

lift_f3_d2
{
	spawn
	{
		wait 200
	}
	trigger open
	{
		gotomarker lift_f3_d2open 140 deccel wait
	}
	trigger close	
	{
		gotomarker lift_f3_dclose 140 deccel wait	
	}
}

